$.fn.serializeObject = function() {
	var o = {};
	var a = this.serializeArray();
	$.each(a, function() {
		if (o[this.name]) {
			if (!o[this.name].push) {
				o[this.name] = [ o[this.name] ];
			}
			o[this.name].push(this.value || '');
		} else {
			o[this.name] = this.value || '';
		}
	});
	return o;
};
var js = {
	path : function() {
		var location = (window.location + '').split('/');
		var url = location[0] + '//' + location[2] + '/' + location[3];
		return url;
	},
	// formId 表单id
	submitProduct : function(formId, msg, error) {
		var obj = $("#" + formId + "");
		// 序列化表单
		var jsonuserinfo = obj.serializeObject();
		var productField = JSON.stringify(jsonuserinfo); // 产品属性
		// var productPrice=obj.find("input[name=productPrice]").val(); //产品价格
		// var paymentType=obj.find("input[name=paymentType]").val(); //产品付费方式
		// var productTime=obj.find("input[name=productTime]").val(); //产品期限
		var orderNo = $("#orderNo").val();
		var options = {
			url : js.path() + "/web/order/addProduct.do",
			type : "post",
			dataType : "json",
			// data:{orderNo:orderNo,productField:productField,productPrice:productPrice,paymentType:paymentType,productTime:productTime},
			data : {
				orderNo : orderNo,
				productField : productField
			},
			success : function(data) {
				if (data.status) {
					alert(msg+"--->"+data.msg);
				} else {
					alert(error+"--->"+data.msg);
				}
			}
		};
		$("#" + formId + "").ajaxSubmit(options);
	},
	closeWin : function() {
		if (window.document.referrer == ""
				|| window.document.referrer == window.location.href) {
			window.location.href = "{dede:type}[field:typelink /]{/dede:type}";
		} else {
			window.location.href = window.document.referrer;
		}

	}
};